'''
Author: LHY 2601958675@qq.com
Date: 2023-06-27 15:47:02
LastEditors: LHY
LastEditTime: 2023-06-28 11:58:50
Description: 
'''
# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html

import scrapy


class TutorialItem(scrapy.Item):
    # define the fields for your item here like:
    title = scrapy.Field()
    link = scrapy.Field()
    desc = scrapy.Field()
    name = scrapy.Field()
    price = scrapy.Field()
    pass

class disp(TutorialItem):
    disc = scrapy.Field(serializer=str)
    disc_ex_data = scrapy.Field()
    # name = scrapy.Field(Product.fields['name'], serializer=my_serializer)


product = TutorialItem(name='Desktop PC', price=1000)
print( product["name"])
print(product.get('price'))
print(product.get('lala'))#获取
print(product.get('lala','unfiled'))#获取lala属性的值 没有属性的话 返回 默认值unfiled 
product["name"] = '我来修改'
print(product["name"])
print(product.keys())
print(product.items)

pro2 = TutorialItem(product)
print(pro2) 

pro3 = pro2.copy()
print(pro3)

print(dict(pro3))
print('!!!!!!')
print(TutorialItem(dict(pro3)))
dis = disp(pro3)
dis['disc'] = 'sadasd'
dis['disc_ex_data'] = 'disc_ex_data'
print(dis)